from google.appengine.ext import db

class Person(db.Model):
	user = db.UserProperty()
	first_name = db.StringProperty()
	last_name = db.StringProperty()
	def __str__(self): return ' '.join(self.first_name, self.last_name)

class Student(db.Model):
	person = db.ReferenceProperty(Person)
	class_year = db.IntegerProperty()
	section = db.StringProperty()
	def __str__(self): return ' '.join('Student:', self.person.first_name, self.person.last_name)

class Tutor(db.Model):
	person = db.ReferenceProperty(Person)
	relationship = db.StringProperty(choices=['mother','father','tutor'])
	student = db.ReferenceProperty(Student)
	def __str__(self): return ' '.join('Student:', self.person.first_name, self.person.last_name)

class Stop(db.Model):
	description = db.StringProperty()
	address = db.PostalAddressProperty()
	geo = db.GeoPtProperty()
	def __str__(self): return self.description

class Path(db.Model):
	stops = db.ListProperty(db.Key)
	def __str__(self): return ' - '.join([stop.description for stop in  self.stops])

class Trip(db.Model):
	date = db.DateTimeProperty()
	path = db.ReferenceProperty(Path)
	is_return = db.BooleanProperty()
	def __str__(self): return str(self.date)

class Driver(db.Model):
	person = db.ReferenceProperty(Person)
	position = db.StringProperty(choices=['front','back'])
	trip = db.ReferenceProperty(Trip)
	def __str__(self): ' '.join('Driver:', self.person.first_name, self.person.last_name)

class Pick(db.Model):
	student = db.ReferenceProperty(Student)
	stop = db.ReferenceProperty(Stop)
	trip = db.ReferenceProperty(Trip)
